Skip to content

revert(gateway): fully revert #2630 upstream target binding - #2920

Merged
hidb4ai merged 6 commits into
masterfrom
codex/revert-pr-2630
Dec 1, 2026
Merged

hidb4ai merged 6 commits into
masterfrom
codex/revert-pr-2630

Conversation

@hidb4ai

@hidb4ai hidb4ai commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Which issue or RFC does this PR close?

Reverts #2630 (squash commit 0237a47dd99379dba8c7f3176c8a3591af7f2f4c). Refs #2460.

Rationale for this change

Restore the Gateway deployment and transport behavior that existed before #2630. #2630 has not been released. Development deployments using PC_GATEWAY_UPSTREAM_URL*, optional Core authentication, or environment HTTP proxies should no longer require the breaking configuration migration introduced by that PR.

What changes are included in this PR?

  • Reverse the feat(gateway): bind Core-approved target to upstream sends #2630 target-binding change across Gateway transport/execution/authentication, Core checks, tests, CI selection, and bilingual documentation.
  • Restore independently configured upstream URLs, ambient proxies, the previous route/profile selection and model checks, and the previous degradation behavior. Remove the privileged approved-target binding from Gateway sends; this intentionally also removes the destination-binding guarantees added by feat(gateway): bind Core-approved target to upstream sends #2630.
  • Resolve documentation conflicts while retaining subsequent request-Scope routing guidance. Translate the later per-Scope authorization guidance to the restored Core-token model (server.observer plus scope.contributor on the default and selected Scopes) instead of dropping it with the target-binding terms.
  • Preserve Add completion-aware outcome guidance to coding plugins #2863 Codex outcome-guidance handling and its regressions, including its tests. Retain the later native migration revision assertion and the artifact-supervisor usage flush fix. Retain the current compatibility rationale and verified persistence digest. No migration or stored schema is reverted.
  • Preserve independent fixes from feat(gateway): bind Core-approved target to upstream sends #2630: direct Core HTTP RPCs (ambient model-egress proxies receive no Core credentials), endpoint port/query/fragment validation, artifact-supervisor usage flushing, native migration revision assertions, and real-listener CI coverage. Conflict resolution preserves unrelated subsequent changes.

Are there any user-facing changes?

Yes. PC_GATEWAY_UPSTREAM_URL* is accepted again; Responses uses its upstream URL rather than PC_GATEWAY_UPSTREAM_PROFILE_RESPONSES. Core credentials are required when Core enforces authentication, and the client key is required for non-loopback listeners. Upstream requests again honor environment proxy configuration. Deployments already migrated to #2630 must restore the previous upstream URL configuration. Two-phase checks remain, using the earlier contract.

How was this change tested?

Latest repair (cdfd44383):

  • Reproduced both regressions before the fix: five invalid endpoint cases were accepted, and the isolated Core proxy test failed.
  • pytest -q tests/builtin/inference/test_privacy.py — 97 passed.
  • cargo test --locked --manifest-path gateway/Cargo.toml -p pc-gateway-core --test core_proxy — passed (2 test entries; the parent also verifies the isolated child). Real loopback Core and proxy listeners verify that only Core receives the authenticated request.
  • cargo clippy --locked --manifest-path gateway/Cargo.toml -p pc-gateway-core --all-targets -- -D warnings, Cargo formatting, and prek run -a — passed.

Earlier validation (not rerun in full on the latest repair):

  • cargo fmt --manifest-path gateway/Cargo.toml --all --check — passed.
  • prek run -a — passed, including Ruff and ty check.
  • pytest -q tests/test_ci_changes.py tests/test_docs_remote_access_contract.py — 192 passed.
  • pnpm check:links — validated 379 public pages and 673 repository files.
  • ruff check tests/native/test_personal_service_lifecycle.py and Python byte-compilation — passed.
  • upgrade_release_gate.load_policy — passed; current persistence digest matches the checkout.
  • cargo check --workspace — passed.
  • git diff --check — passed. The independent fixes intentionally retained are listed above.
  • cargo test --locked --manifest-path gateway/Cargo.toml --workspace — 349 passed, including mandatory real-Core RPC recovery tests. Optional external Core tests can return early when unavailable; this is not external-provider acceptance.
  • cargo clippy --locked --manifest-path gateway/Cargo.toml --all-targets -- -D warnings — passed.
  • pytest -q tests/e2e/test_gateway_authentication.py tests/e2e/test_gateway_http1_lifecycle.py — 41 passed in 534.72 seconds. Real Python Core/SQLite over UDS and Rust Gateway listeners with fixture providers cover authentication, disconnect/delivery/fallback, staged shutdown, and the unchanged 180-second request deadline. No external model provider was used.
  • Fresh git merge-tree --write-tree HEAD origin/master — conflict-free against master 246f70beb.

External-provider, installed-host, and native database upgrade acceptance are not claimed. GitHub CI must validate this PR's current head and merge result before merge.

AI usage statement

Implemented and validated with OpenAI Codex (GPT-6). The contributor remains responsible for the changes.

Reverts 0237a47. Preserve subsequent Scope documentation, Codex outcome guidance, and the current persistence digest; adapt Dify references to the restored configuration contract.

@NeverENG NeverENG left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reviewed this revert against both the pre-#2630 parent and current master. I did not find a compile-level or dangling-reference problem: the persistence digest is preserved, the Core target-resolution endpoint predates #2630, deleted test references are cleaned up, and most CI is green.

The inline comments cover the concrete issues I found. One additional risk is worth making explicit: this is a security-boundary rollback (separate API/Core credentials, Core-token bearer validation, target/model mismatch guard, and stricter endpoint validation). That is expected for a revert, but it should be a conscious release/security decision rather than only a code revert.

check-website is currently red because of an unrelated next/font Google Fonts loader error (TypeError: Cannot read properties of null (reading '1') in src/app/fonts.ts); gateway-validation / check is still pending at the time of this review.

Comment thread release/upgrade-support.json Resolved
Comment thread tests/e2e/artifact_supervisor_real.py Resolved
Comment thread .github/workflows/gateway.yml Resolved
Comment thread docs/en/docs/integrations/dify.md Resolved
NeverENG and others added 3 commits November 30, 2026 17:22
Keep the later master persistence rationale that the #2630 revert dropped, restore the supervisor usage flush/timeout stabilization, and continue running the remaining real Gateway listener acceptance tests. Also keep gateway path selection in sync with the restored listener suites.
Adapt later per-Scope authorization guidance to the restored pre-#2630 gateway model instead of dropping it with the target-binding revert. Keep the native migration test reading the reviewed target revision and verifying the stored schema revision.
@NeverENG

Copy link
Copy Markdown
Collaborator

Coordination note: #2925 restores every configuration that works on the v1.6.0 release — legacy PC_GATEWAY_UPSTREAM_URL*, optional PC_GATEWAY_CORE_TOKEN, optional loopback client key, ambient proxy egress, the Responses profile defaulting to the Chat profile, and PC_GATEWAY_DEGRADE=pause — and keeps the #2460 binding whenever Core can resolve a target:

  • startup posture bound / compatible / paused, derived from Core capabilities plus access control;
  • in bound posture a legacy destination becomes an assertion against the approved endpoint (URL semantics; mismatch means zero send);
  • PC_GATEWAY_TARGET_BINDING=required keeps the strict fail-closed behavior on demand.

With #2925 in place this full revert no longer has a compatibility gap to close, while it would drop the #2460 P0 guarantees and the real-listener A/B acceptance that already pass. Suggest narrowing this PR to the items still considered necessary — I do not see any that are required for 1.6.0 parity — or closing it. If both land anyway, the overlap is in gateway/** and the docs, so one side will need a rebase.

@hidb4ai hidb4ai added 1.6.1 v1.6.1 release tracking and removed 1.6.2 v1.6.2 release tracking labels Nov 30, 2026
@AlexStocks AlexStocks removed the 1.6.1 v1.6.1 release tracking label Nov 30, 2026
@hidb4ai hidb4ai added the 1.6.1 v1.6.1 release tracking label Nov 30, 2026
@hidb4ai

hidb4ai commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

Re-reviewed cdfd44383ad36bda08b4b768160b6718dbd5409c. The two regressions I previously confirmed (ambient proxy exposure of Core credentials and invalid endpoint acceptance) are fixed. The current executable also completed real Core + SQLite + external-provider calls in both disabled and enforcing modes, with release_authorized and one upstream attempt per call.

The remaining issue is the existing team-installation finding. I independently confirmed that appending the callback credentials invalidates the environment-file identity recorded at installation, while the loaded configuration still lacks those headers. This was a loader-boundary reproduction, not an installed-service test. Please restore validation and service reinstallation after writing the callback credentials in both locales, or write the complete configuration before the initial installation. I am referencing that thread rather than opening a duplicate.

@frf12 frf12 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed ce622a7. The installation finding is resolved in both locales: callback credentials are written before configuration validation and the appropriate service refresh. Shell-command, configuration-readback and controller identity-refresh checks passed using a fake native manager; no installed service was restarted. The retained direct Core RPC transport and endpoint validation were also reviewed. The overflow-evidence wording remains a non-blocking documentation follow-up. Current-head CI is still running and must pass before merge.

@hidb4ai
hidb4ai merged commit d426e2d into master Dec 1, 2026
96 checks passed
@hidb4ai
hidb4ai deleted the codex/revert-pr-2630 branch December 1, 2026 09:08
Fengzdadi added a commit to Fengzdadi/powercontext that referenced this pull request Dec 1, 2026
oceanbase#2920 reverted oceanbase#2630, so the gateway again reaches the upstream through
PC_GATEWAY_UPSTREAM_URL_RESPONSES, Core's target comes from
PC_GATEWAY_UPSTREAM_PROFILE, and no gateway.user grant or enforced access
mode is required. Align the DSH guide (en and zh) with that setup and link
the restored Gateway authentication boundaries section.
Fengzdadi added a commit to Fengzdadi/powercontext that referenced this pull request Dec 1, 2026
…cope-header

Resolve pi.md (en/zh) and the Pi gateway e2e on oceanbase#2920's restored gateway setup: the
gateway reaches the provider through PC_GATEWAY_UPSTREAM_URL_RESPONSES, its Core
credential is granted server.observer and scope.contributor, and the e2e no longer
grants gateway.user.
Fengzdadi added a commit to Fengzdadi/powercontext that referenced this pull request Dec 1, 2026
Resolve opencode.md (en/zh) in favor of master's restored gateway target paragraph from oceanbase#2920.
Fengzdadi added a commit to Fengzdadi/powercontext that referenced this pull request Dec 1, 2026
oceanbase#2920 reverted the Core target contract. The guide and the gateway e2e return to master's setup: PC_GATEWAY_UPSTREAM_URL_RESPONSES with PC_GATEWAY_UPSTREAM_PROFILE, PC_GATEWAY_API_KEY on non-loopback listeners, and, when Core enforces authentication, server.observer and scope.contributor for the gateway's Core identity on every Scope a request selects.
hidb4ai pushed a commit that referenced this pull request Dec 2, 2026
* feat(dsh): let the gateway own prompt-time context

Add POWERCONTEXT_DSH_PROMPT_RECALL (patch key promptRecall, default true).
With it off, the pre-step hook prepares and appends nothing, the companion
memory service is not provided, and agent-loop model requests carry
X-PowerContext-Conversation-ID through llm-pi-ai/request-headers. Document
routing DSH 0.2.2 through the gateway's Responses route.

* docs(dsh): note that the gateway captures DSH session-title requests

A real DSH 0.2.2-rc.5 run behind the gateway with PC_GATEWAY_SEDIMENT=on stored each session-title request as a gateway turn of its inferred conversation, with the title prompt as the user text.

* docs(dsh): name the DSH versions that cannot send the conversation header

The llm-pi-ai/request-headers hook is already in dsh-llm-pi-ai 0.2.2-alpha.3 and absent in 0.2.1-rc.5 and 0.2.0-rc.2.

* feat(dsh): mark DSH's internal model requests for the gateway

While prompt recall is off, requests that DSH sends with a purpose (compaction, session titles, auto review) carry X-PowerContext-Turn: internal instead of no header, so the gateway neither injects context into them nor captures them as turns. The guide now says so, and states that the plugin does not send X-PowerContext-Scope-ID.

* docs(dsh): drop the gateway reminder limit now that #2771 is merged

* docs(dsh): configure the gateway with #2630's model destination contract

* fix(dsh): keep Scope routing in the runtime context while recall is off

With prompt recall off the pre-step adds no message, because behind the
gateway any message after the prompt would replace it as the turn. That
also removed the Scope routing, which the guidance requires for MCP
operations that take a scope_id.

While recall is off, the plugin now contributes the routing to DSH's
runtime context (powercontext:scope-routing, required, not interpolated).
DSH refreshes that context after the pre-step and sends it as a standalone
<system-reminder> user message only when it changes; the gateway does not
take such a message as the turn (#2771). The guidance and the DSH guide
name both places the routing can appear.

* docs(dsh): configure the gateway with master's restored upstream setup

#2920 reverted #2630, so the gateway again reaches the upstream through
PC_GATEWAY_UPSTREAM_URL_RESPONSES, Core's target comes from
PC_GATEWAY_UPSTREAM_PROFILE, and no gateway.user grant or enforced access
mode is required. Align the DSH guide (en and zh) with that setup and link
the restored Gateway authentication boundaries section.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1.6.1 v1.6.1 release tracking

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants